
var data_zh = ['你知道吗', '六月', '一日', '星期一', '是', '儿童节'];
var data_en = ['do you know', 'June', 'One day', 'Monday', 'Yes', 'Children\'s day'];


var b1 = document.querySelectorAll("#b1 button");
var b2 = document.querySelectorAll("#b2 button");

var long = "zh";
function swap() {
    if (long==="zh"){
        long = "en";
    }else {
        long = "zh";
    }

    for(var i=0;i<b1.length; i++){
        b1[i].classList.remove("btn-primary");
        b1[i].classList.remove("btn-light");
        b2[i].classList.remove("btn-primary");
        b2[i].classList.remove("btn-light");
    }
    switch (long){
        case "en":
            b1[0].classList.add("btn-light");
            b1[1].classList.add("btn-primary");
            b2[0].classList.add("btn-light");
            b2[1].classList.add("btn-primary");
            break;
        case "zh":
            b1[0].classList.add("btn-primary");
            b1[1].classList.add("btn-light");
            b2[0].classList.add("btn-primary");
            b2[1].classList.add("btn-light");
            break;
    }
}


var t3 = document.querySelector(".t1");
var t4 = document.querySelector(".t2");
function  zhToEn(){
    for(var i=0;i<data_zh.length;i++){
        if (t3.value == data_zh[i]){
            t4.value = data_en[i];
            if (long==="zh"){
                swap();
            }
        }else if (t3.value == data_en[i]){
            t4.value = data_zh[i];
            if (long =="en"){
                swap();
            }
        }
    }
}